package com.thiswhyme.republish.rabbitmq.core.domain;

/**
 * 重发状态
 * Created by thiswhyme on 2021-03-21.
 */
public enum PublishStatus {

    SEND_TO_ACK(1, "待ACK-发送"),
    SEND_SUCCESS(2, "发送成功"),
    FAIL(3, "重试失败或重试结束仍然失败"),
    NONE(4, "无需重试"),
    CONSUME_TO_ACK(5, "待ACK-消费"),
    CONSUME_SUCCESS(6, "消费成功");

    PublishStatus(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    private Integer value;
    private String desc;

    public Integer getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    public static PublishStatus indexOf(int value) {
        for (PublishStatus item : PublishStatus.values()) {
            if (item.value == value) {
                return item;
            }
        }

        return null;
    }

    public static PublishStatus nameOf(String name) {
        for (PublishStatus item : PublishStatus.values()) {
            if (item.toString().equals(name)) {
                return item;
            }
        }
        return null;
    }

}
